﻿namespace Huayou.Utils
{
    using System;

    public class TickUtils
    {
        public static long AddDays(long tick, int daydiff)
        {
            return (tick + (0x5265c00L * daydiff));
        }

        public static DateTime ConvertToDateTime(long tick)
        {
            return new DateTime(tick * 0x2710L);
        }

        private static long ConvertToMilli(long nano)
        {
            return (nano / 0x2710L);
        }

        public static string DateFormat(long tick)
        {
            return DateUtils.DateFormat(ConvertToDateTime(tick));
        }

        public static string DateFormat(long tick, string format)
        {
            return DateUtils.DateFormat(ConvertToDateTime(tick), format);
        }

        public static string DateTimeFormat(long tick)
        {
            return DateUtils.DateTimeFormat(ConvertToDateTime(tick));
        }

        public static string DateTimeFormat(long tick, string format)
        {
            return DateUtils.DateTimeFormat(ConvertToDateTime(tick), format);
        }

        public static long GetTick()
        {
            return ConvertToMilli(DateTime.Now.Ticks);
        }

        public static long GetTick(string date)
        {
            return ConvertToMilli(Convert.ToDateTime(date).Ticks);
        }
    }
}

